package com.jasen.springcloud.service;


import com.jasen.springcloud.entities.Dept;
import org.springframework.cloud.netflix.feign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;

import java.util.List;

/**
 * @FeignClient 向哪个微服务进行面向接口的编码
 * @FeignClient(value = "microservicecloud-dept") 在对外提供的接口上配置好提供服务的名称，对于服务消费者无需关心
 *  此服务的地址信息，见microservicecloud-consumer-dept-feign-80#DeptController_Consumer
 *
 *  服务降级添加的配置：
 *      fallbackFactory = DeptClientServiceFallbackFactory.class
 *     在消费者端添加依赖spring-cloud-starter-hystrix（1.3.1.RELEASE），否则熔断不会生效（springcloud版本Dalston.SR1）
 */
@FeignClient(value = "microservicecloud-dept", fallbackFactory = DeptClientServiceFallbackFactory.class)
public interface DeptConsumerService {

    @GetMapping("/dept/get/{id}")
    public Dept get(@PathVariable("id") Long id);

    @GetMapping("/dept/list")
    public List<Dept> list();

    @PostMapping("/dept/add")
    public Boolean add(Dept dept);

    @GetMapping(value="/dept/discovery")
    public Object discovery();

}
